<template>
  <div>
    <h1 class="text-center text-white bg-blue-500 text-md py">H5 - template - vue2</h1>
    <div class="my-2x p-3x">
      <ol class="leading-loose">
        <li>账户：{{ $store.getters.name }}</li>
        <li>Token：{{ $store.getters.token }}</li>
        <li>账户类型：{{ $store.state.user.loginType }}</li>
      </ol>
      <van-divider class="py-3x">
        <van-icon name="star-o" v-for="i in 5" :key="i" />
      </van-divider>
      <van-button type="primary" block round @click="onLogout">退出登录</van-button>
    </div>
  </div>
</template>
<script>
import { Dialog } from 'vant';

export default {
  name: 'Home',
  methods: {
    onLogout() {
      Dialog.confirm({
        title: '确认退出登录',
        message: '确定要退出吗？'
      })
        .then(async () => {
          await this.$store.dispatch('user/logout');
          this.$router.push(`/login?redirect=${this.$route.fullPath}`);
        })
        .catch(() => {});
    }
  }
};
</script>
